package com.cskaoyan.bean;

import com.cskaoyan.bean.po.admin.role.MarketPermissionDetails;
import lombok.NoArgsConstructor;

import java.lang.reflect.Field;

/**
 * @author MoJunXiang
 * @since 2022/09/09 16:03
 */
@NoArgsConstructor
public class MarketPermissionDetailsColumns {
    private Boolean id = false;
    private Boolean mid = false;
    private Boolean mid_str = false;
    private Boolean cid = false;
    private Boolean cid_str = false;
    private Boolean aid = false;
    private Boolean aid_str = false;
    private Boolean aid_label = false;
    private Boolean api = false;


    public void addColumn(String fieldName) throws NoSuchFieldException, IllegalAccessException {
        Class<? extends MarketPermissionDetailsColumns> columnsClazz = this.getClass();
        Field field = columnsClazz.getDeclaredField(fieldName);
        field.setAccessible(true);
        field.set(this, true);
    }

    public void addAllColumns() throws IllegalAccessException {
        Class<? extends MarketPermissionDetailsColumns> columnsClazz = this.getClass();
        Field[] fields = columnsClazz.getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            field.set(this, true);
        }
    }

}
